package com.example.docking.service.impl;

import com.example.docking.dao.jindie.GenericDataItem;
import com.example.docking.dao.jindie.ResponseData;
import com.example.docking.dao.jindie.response.CustomerData;
import com.example.docking.service.CustomerService;
import com.example.docking.util.Constants;
import com.google.gson.Gson;
import com.smecloud.apigw.model.ApiResult;

import java.util.HashMap;

public class CustomerServiceImpl extends BaseServiceImpl implements CustomerService {
    @Override
    public ApiResult SelectCustomer() throws Exception {
        int page = 2; // 初始页码
        int pageSize = 10; // 每页记录数
        HashMap<String, String> map = new HashMap<>();
        map.put("page", String.valueOf(page));
        map.put("page_size", String.valueOf(pageSize));
        return sendApiRequestGet(Constants.MATERIAL_PATH, map, "");
    }

    public static void main(String[] args) throws Exception {
        Gson gson = new Gson();
        CustomerService service = new CustomerServiceImpl();
        ApiResult result = service.SelectCustomer();
        ResponseData<GenericDataItem<CustomerData>> response = gson.fromJson(result.getBody(), ResponseData.class);
        System.out.println("Code: " + response.getErrcode());
        System.out.println("Message: " + response.getDescription());
        System.out.println("data: " + response.getData());

    }
}
